home *** CD-ROM | disk | FTP | other *** search
- Path: baekdu.rgit.wustl.edu!kks
- From: kks@rgit.wustl.edu (Kyeong Soo Kim)
- Newsgroups: comp.lang.c,comp.lang.c++
- Subject: [Q] Multi-dimensional array problem!!!!!
- Date: 18 Apr 1996 19:26:39 GMT
- Organization: Washington University, St. Louis, MO
- Message-ID: <4l651f$p8v@oldfart.ecl.wustl.edu>
- NNTP-Posting-Host: baekdu____,.wustl.edu
- Keywords: array
- X-Newsreader: TIN [version 1.2 PL2]
-
- Dear colleagues,
-
-
- I have a difficult problem (?) to be solved for my research.
- In most cases, only the size of the array can be input
- parameters given at run time with its dimension fixed in
- programs. I know this could be done by dynamic allocation
- using calloc or malloc as in "Numerical Recipe in C".
-
- But, in my case, the dimension as well as the size of the
- array is also an input parameter for the program. That is,
- while I must treat 3x4 array in one situation, I must treat
- 3x4x5 array in the other situation. One of the most simple
- example is as follows:
-
-
- * Summarize all the elements of the array A[a1][a2]...[an].
-
- sum = 0.0;
- for (i1 = 0; i1 < a1; i1++)
- . . .
- for (in = 0; in < an; in++)
- sum += A[i1][i2]...[in];
-
-
- Of course, the above part cannot be implemented with C/C++
- as it is. So I don't know how to achieve my purpose.
- If would be greatly appreciated if you could give me
- any information or advices as soon as possible.
- Thanks in advance!
-
-
- Kyeong Soo Kim
- =================================================================
- Kim, Kyeong Soo
- -----------------------------------------------------------------
- Bryan Hall, Room 426 * EMAIL: kks@rgit.wustl.edu
- Department of Electrical Engineering * TEL : +1-314-935-6157 (O)
- Washington University +1-314-872-8973 (H)
- St. Louis, MO, 63130, USA * FAX : +1-314-935-7500 (O)
- =================================================================
-